package cn.hdustea.shopNavigation.callback;

import java.util.WeakHashMap;

/**
 * Created by HuQiang on 2017/11/23.
 */

public class CallBackManager {
    private static final WeakHashMap<Object, IGlobalCallback> CALLBACKS = new WeakHashMap<>();

    private static final class Holder {
        private static final CallBackManager INSTANCE = new CallBackManager();
    }

    public static CallBackManager getInstance() {
        return Holder.INSTANCE;
    }

    public final CallBackManager addCallback(Object key, IGlobalCallback iGlobalCallback) {
        CALLBACKS.put(key, iGlobalCallback);
        return this;
    }

    public IGlobalCallback getCallBack(Object key) {
        return CALLBACKS.get(key);
    }
}
